package com.ruoyi.bigScreen;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.zzw.TCaseInfo;
import com.ruoyi.common.core.domain.zzw.VO.RenderingDataVO;
import com.ruoyi.common.core.domain.zzw.VO.TCaseInfoListVO;
import com.ruoyi.common.core.domain.zzw.VO.byType;
import com.ruoyi.common.core.domain.zzw.VO.byTypeVO;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.ITCaseInfoService;

/**
 * 民转刑事案件详情Controller
 * 
 * @author ruoyi
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/system/info")
@Api(tags = "民转刑事案件管理")
public class TCaseInfoController extends BaseController
{
    @Autowired
    private ITCaseInfoService tCaseInfoService;

    /**
     * 查询民转刑事案件详情列表
     */
    @ApiOperation("查询民转刑事案件详情列表")
    @GetMapping("/list")
    public AjaxResult list(TCaseInfo tCaseInfo)
    {
        List<TCaseInfoListVO> list = tCaseInfoService.selectTCaseInfoList(tCaseInfo);
        return success(list);
    }

    /**
     * 获取民转刑事案件详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{cCaseId}")
    public AjaxResult getInfo(@PathVariable("cCaseId") Long cCaseId)
    {
        return success(tCaseInfoService.selectTCaseInfoByCCaseId(cCaseId));
    }

    /**
     * 新增民转刑事案件详情
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "民转刑事案件详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCaseInfo tCaseInfo)
    {
        return toAjax(tCaseInfoService.insertTCaseInfo(tCaseInfo));
    }

    /**
     * 修改民转刑事案件详情
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "民转刑事案件详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCaseInfo tCaseInfo)
    {
        return toAjax(tCaseInfoService.updateTCaseInfo(tCaseInfo));
    }

    /**
     * 删除民转刑事案件详情
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "民转刑事案件详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cCaseIds}")
    public AjaxResult remove(@PathVariable Long[] cCaseIds)
    {
        return toAjax(tCaseInfoService.deleteTCaseInfoByCCaseIds(cCaseIds));
    }

    @ApiOperation("通过地区统计案件数量(在地图上展示热力图)")
    @GetMapping("/byRegion")
    public AjaxResult byRegion(){
        List<RenderingDataVO> vo=  tCaseInfoService.byRegion();
        return success(vo);
    }

    @ApiOperation("通过案件类型统计占比和总数，并且计算各案件的潜在因素转隐患概率、处置隐患概率、潜在因素转刑事案件概率的平均数")
    @GetMapping("/average")
    public AjaxResult average(){
        return success(tCaseInfoService.average());
    }

    @ApiOperation("根据指标获取图形json")
    @GetMapping("/byType")
    public AjaxResult byType(String type){
        byTypeVO vo=tCaseInfoService.byType(type);
        return success(vo);
    }
}
